package com.carp.controller;

import com.carp.common.DBResult;
import com.carp.entity.CarpArticle;
import com.carp.service.CarpArticleService;
import com.carp.service.CarpIndexService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;

@RestController
@RequestMapping("/index")
public class IndexController {
    @Resource
    private CarpIndexService carpIndexService;

    @PostMapping("/articleSum")
    public DBResult toArticleSum(@RequestParam(value = "uid",defaultValue = "0") Integer uid){

        //获取每季度的文章总数
        List<Integer> integersAll = carpIndexService.articleAll();
        //获取每季度个人文章总数
        List<Integer> integers = carpIndexService.personalArticle(uid);

        HashMap<String, Object> map = new HashMap<>();
        map.put("articleAll",integersAll);
        map.put("personalAll",integers);

        return DBResult.success(map);
    }
}
